﻿using System.Windows;
using Catel.Articles._03___MVVM.UI.ViewModels;
using Catel.MVVM.UI;
using Catel.Windows;

namespace Catel.Articles._03___MVVM.Examples.ControlToViewModelWithWindow
{
    /// <summary>
    /// Interaction logic for WindowWithViewModelMappings.xaml
    /// </summary>
    public partial class WindowWithViewModelMappings : DataWindow<PersonViewModel>
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="WindowWithViewModelMappings"/> class.
        /// </summary>
        public WindowWithViewModelMappings()
        {
            // Initialize component
            InitializeComponent();
        }

        /// <summary>
        /// Gets or sets the first name.
        /// </summary>
        /// <value>The first name.</value>
        [ControlToViewModel]
        public string FirstName
        {
            get { return (string)GetValue(FirstNameProperty); }
            set { SetValue(FirstNameProperty, value); }
        }

        // Using a DependencyProperty as the backing store for FirstName.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty FirstNameProperty =
            DependencyProperty.Register("FirstName", typeof(string), typeof(WindowWithViewModelMappings), new UIPropertyMetadata(string.Empty));
    }
}
